/*
 * Copyright 2010 Katsunori Koyanagi
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package sweezy.anim.impl
{
	import flash.display.DisplayObject;
	import flash.geom.ColorTransform;
	import flash.geom.Matrix;
	import flash.geom.Point;
	import sweezy.anim.core.IAnimatableObject;
	import sweezy.anim.core.IUpdater;
	import sweezy.anim.updater.core.AnimatableObjectUpdater;
	import sweezy.anim.updater.display.DisplayObjectUpdater;
	import sweezy.anim.updater.filters.BevelFilterUpdater;
	import sweezy.anim.updater.filters.BlurFilterUpdater;
	import sweezy.anim.updater.filters.DropShadowFilterUpdater;
	import sweezy.anim.updater.filters.GlowFilterUpdater;
	import sweezy.anim.updater.filters.GradientBevelFilterUpdater;
	import sweezy.anim.updater.filters.GradientGlowFilterUpdater;
	import sweezy.anim.updater.geom.ColorTransformUpdater;
	import sweezy.anim.updater.geom.MatrixUpdater;
	import sweezy.anim.updater.geom.PathUpdater;
	import sweezy.anim.updater.geom.PointUpdater;

	internal class Updaters
	{

		private static var _updaters:Array = [
			//built in type
			AnimatableObjectUpdater, [IAnimatableObject],

			//display object
			DisplayObjectUpdater, [DisplayObject],

			//geom object
			PointUpdater, [Point],
			MatrixUpdater, [Matrix, "matrix"],
			ColorTransformUpdater, [ColorTransform, "colortransform", "color"],
			PathUpdater, ["path", "bezier"],

			//filter object
			BlurFilterUpdater, ["blur", "blurfilter"],
			BevelFilterUpdater, ["bevel", "bevelfilter"],
			GlowFilterUpdater, ["glow", "glowfilter"],
			DropShadowFilterUpdater, ["dropshadow", "dropshadowfilter"],
			GradientBevelFilterUpdater, ["gradientbevel", "gradientbevelfilter"],
			GradientGlowFilterUpdater, ["gradientglow", "gradientglowfilter"],
			];

		public static function init(manager:AnimationManager):void
		{
			for (var i:int = 0, len:uint = _updaters.length / 2; i < len; i++)
			{
				var type:Class = _updaters[i * 2];
				var params:Array = _updaters[i * 2 + 1];
				var updater:IUpdater = new type();

				for (var j:int = 0, len2:uint = params.length; j < len2; j++)
				{
					var param:Object = params[j];
					if (param is String)
					{
						manager.registerUpdaterByPrefix(param as String, updater);
					}
					else if (param is Class)
					{
						manager.registerUpdaterByElementType(param as Class, updater);
					}
				}
			}
		}
	}
}
